<?php

include '../function.php'; 

$dsn = "mysql:host=localhost;dbname=school";
$username="root";
$password = "";

try{
	$pdo = new Pdo($dsn,$username,$password);

}catch(PDOException $e) {
	exit($e->getMessage());
}

$pdo->query("set names utf8");

// $sql ="select * from stu";

// $res = $pdo->query($sql);

// $all = $res->fetchAll(PDO::FETCH_ASSOC);


$sql ="insert into stu (name,sex) value('小明明','男')";

$res = $pdo->exec($sql);

var_dump($pdo->lastInsertId());






// try {
// 	$sql = "insert into stu(sname) values(?)";
// 	$state = $pdo->prepare($sql);
// 	$sname = "baidu";
// 	$state->bindParam(1,$sname,PDO::PARAM_STR);
// 	$state->execute();
// } 
// catch (PDOException $e) {
// 	exit($e->getMessage());
// }














 ?>